Page({
    data: {
      listData:[
        {"code":"01","temp":"22","hum":"36","fire":"0","time":"2022-01-01 01:01:01"},
        {"code":"02","temp":"22","hum":"36","fire":"0","time":"2022-01-01 01:01:01"},
        {"code":"03","temp":"22","hum":"36","fire":"0","time":"2022-01-01 01:01:01"},
        {"code":"04","temp":"22","hum":"36","fire":"0","time":"2022-01-01 01:01:01"},
        {"code":"05","temp":"22","hum":"36","fire":"0","time":"2022-01-01 01:01:01"},
        {"code":"06","temp":"22","hum":"36","fire":"0","time":"2022-01-01 01:01:01"},
        {"code":"07","temp":"22","hum":"36","fire":"0","time":"2022-01-01 01:01:01"},
        {"code":"08","temp":"22","hum":"36","fire":"0","time":"2022-01-01 01:01:01"},
        {"code":"09","temp":"22","hum":"36","fire":"0","time":"2022-01-01 01:01:01"},
        {"code":"10","temp":"22","hum":"36","fire":"0","time":"2022-01-01 01:01:01"},
        {"code":"11","temp":"22","hum":"36","fire":"0","time":"2022-01-01 01:01:01"},
        {"code":"12","temp":"22","hum":"36","fire":"0","time":"2022-01-01 01:01:01"},
        {"code":"13","temp":"22","hum":"36","fire":"0","time":"2022-01-01 01:01:01"},
        {"code":"14","temp":"22","hum":"36","fire":"0","time":"2022-01-01 01:01:01"},
        {"code":"15","temp":"22","hum":"36","fire":"0","time":"2022-01-01 01:01:01"},
        {"code":"16","temp":"22","hum":"36","fire":"0","time":"2022-01-01 01:01:01"},
        {"code":"17","temp":"22","hum":"36","fire":"0","time":"2022-01-01 01:01:01"}
      ]
    },
    onLoad: function () {
     var that = this;
      this.setData({                    //每隔一分钟刷新一次
        timer: setInterval(function () {
          that.getDataInfo()
        }, 2000)
     })  
    },
    getDataInfo() {
      var that = this;
      wx.request({
        url: 'http://39.105.114.119:1616/wenshidu/local',
        success(res1) {
         // console.log(res1);
          wx.request({
            url: 'http://39.105.114.119:1616/fire/local',
            success(res) {
            // console.log(res);
              var arr =[];
              for(let i = 0 ;i<25;i++)
              {
                  var obj = {};
                  obj.code = i;
                  obj.temp = res1.data.data[i].temperature;
                  obj.hum = res1.data.data[i].humidity;
                  obj.time = res1.data.data[i].time;
                  obj.fire = res.data.data[i].data;
                  arr.push(obj);
              }
              //console.log(listData)
              that.setData({
                listData : arr
              })
              /*let data = res.data.data
              let temp = [] ,hum = []
              for(let i = data.length-1;i>data.length-11;i--){
               temp.push(parseFloat(data[i].temperature));
               hum.push(parseInt(data[i].humidity))
              }
              that.setData({
                listData.temp = temp;
                listData.hum = hum;
              }) */ 
           }
         }) 
        },
      })
    }
   
  
  })